<?php

class {@acname}Action extends Action
{
    public function index()
    {
        $this->display();
    }
	<loop name="tables" id="vo" token="table">
	//{@vo[tname]}表操作
    public function {@vo[lowtname]}add(){
    	$this->display();
    	
    }
    public function {@vo[lowtname]}addsave(){
    	${@vo[lowtname]}=new {@vo[tname]}Model();
    	if(!${@vo[lowtname]}->create()){
    		$this->error(${@vo[lowtname]}->getError());
    	}else{
    	${@vo[key]}=${@vo[lowtname]}->add();
    	$this->assign("jumpUrl",U("{@acname}/{@vo[lowtname]}content",array('{@vo[key]}'=>${@vo[key]})));
    	$this->success("添加成功");
    	}
    }
    public function {@vo[lowtname]}list(){
    	${@vo[lowtname]}=new {@vo[tname]}Model();
        $pagesize=15;
        import("ORG.Util.Page");
        $totalnum=${@vo[lowtname]}->count();
        $list=${@vo[lowtname]}->page($_GET['p'])->order("id desc")->limit(15)->select();
        $this->assign("list",$list);
        $page=new Page($totalnum,15);
        $page->rollPage=15;     
    	$page->setConfig("prev","上一页");
    	$page->setConfig("next","下一页");
    	$page->setConfig("first","首页");
    	$page->setConfig("last","末页");
    	$page->setConfig("theme","共%totalRow%%header%条数据 %nowPage%/%totalPage%页  %first% %upPage%   %linkPage%  %downPage% %end%");
    	$pageshow=$page->show();
    	$this->assign("pageshow",$pageshow);
    	$this->display();
    }
    public function {@vo[lowtname]}admin(){
    	${@vo[lowtname]}=new {@vo[tname]}Model();
        import("ORG.Util.Page");
        $totalnum=${@vo[lowtname]}->count();
        $list=${@vo[lowtname]}->page($_GET['p'])->limit(10)->select();
        $this->assign("list",$list);
        $page=new Page($totalnum,10);
        $page->rollPage=10;
    	$page->setConfig("header",$header);
    	$page->setConfig("prev","上一页");
    	$page->setConfig("next","下一页");
    	$page->setConfig("first","首页");
    	$page->setConfig("last","末页");
    	$page->setConfig("theme","共%totalRow%%header%条数据 %nowPage%/%totalPage%页  %first% %upPage%   %linkPage%  %downPage% %end%");
    	$pageshow=$page->show();
    	$this->assign("pageshow",$pageshow);
    	$this->display();
    }
    public function {@vo[lowtname]}update(){
    	${@vo[lowtname]}=new {@vo[tname]}Model();
    	$data=${@vo[lowtname]}->where("{@vo[key]}='{$_GET['{@vo[key]}']}'")->find();
    	$this->assign("data",$data);
    	$this->display();
    }
    public function {@vo[lowtname]}updatesave(){
    	${@vo[lowtname]}=new {@vo[tname]}Model();
    	if(!${@vo[lowtname]}->create()){
    		$this->error(${@vo[lowtname]}->getError());
    	}else{
    		${@vo[lowtname]}->save();
    		$this->success("修改成功");
    	}
    }
    public function {@vo[lowtname]}content(){
    	${@vo[lowtname]}=new {@vo[tname]}Model();
    	$data=${@vo[lowtname]}->where("{@vo[key]}='{$_GET['{@vo[key]}']}'")->find();
    	$this->assign("data",$data);
    	$this->display();
    }
    public function {@vo[lowtname]}del(){
     ${@vo[lowtname]}=new {@vo[tname]}Model();
     if(!${@vo[lowtname]}->delete($_GET['{@vo[key]}'])){
     	$this->error("删除失败");
     }else{
     	$this->success("删除成功");
     }
    }
    </loop>
    public function _empty(){ 
   //空操作
    $this->error("您访问的页面不存在！");
    } 
 
}
?>